package com.my.chapter10;

public class practice23 {
    public static void main(String[] args) {
        A23 a = new A23();
        B23 b = new B23();
        b.putU(a.getU());
        b.putU(a.getU());
        b.putU(a.getU());
        b.show();
        b.clear(0);
        System.out.println("");
        b.show();
    }
}


interface U{
    String way1();
    String way2();
    String way3();
}

class A23{
    U getU(){
        return new U() {
            @Override
            public String way1() {
                return "A.way1";
            }

            @Override
            public String way2() {
                return "A.way2";
            }

            @Override
            public String way3() {
                return "A.way3";
            }
        };
    }
}

class B23{
    U[] u=new U[3];
    int index=0;
    void putU(U a){
        if(index<u.length){
            u[index++]=a;
        }
        else{
            System.out.println("is fiool");
        }
    }
    void clear(int x){
        u[x]=null;
    }
    void show(){
        for(int i=0;i<u.length;i++){
            if(u[i]!=null){
                System.out.println("u["+ i +"]={"+ u[i].way1() + "," + u[i].way2() + "," + u[i].way2() +"}");
            }
        }
    }
}

